// api.js
import { reqloading, req } from '../plugins/request'

export function getcustombook () {
  return reqloading({ // 需要loading加载
    url: '/user/customBook/',
    method: 'get'
  })
}

export function getallip (params) {
  return req({
    url: '/user/getip/',
    method: 'get',
    params: params
  })
}

export function getip () {
  return req({
    url: '/user/getip/',
    method: 'post',
    data: ''
  })
}

export function getWebAllBook (params) {
  return req({
    url: '/user/books/',
    method: 'get',
    params: params
  })
}
// 推荐书籍
export function changeCommen (id) {
  return reqloading({ // 需要loading加载
    url: `/user/customBook/${id}/`,
    method: 'post'
  })
}

export function postbook (data) {
  return req({
    url: '/user/books/',
    method: 'post',
    data: data
  })
}

export function deletebook (id) {
  return req({
    url: `/user/books/${id}/`,
    method: 'delete'
  })
}

export function putbook (id, data) {
  return req({
    url: `/user/books/${id}/`,
    method: 'put',
    data: data
  })
}

// 获取当天最热
export function getTodayHot (params) {
  return req({
    url: '/user/todayhot/',
    method: 'get',
    params: params
  })
}

// 审核书籍是否通过
export function shbook (id, data) {
  return req({
    url: `/user/reqBook/${id}/`,
    method: 'put',
    data: data
  })
}

// admin修改用户
export function cguser (id, data) {
  return req({
    url: `/user/cgactive/${id}/`,
    method: 'put',
    data: data
  })
}

// admin修改密码
export function cgpassword (id, data) {
  return req({
    url: `/user/cgpassword/${id}/`,
    method: 'put',
    data: data
  })
}
export function postAdminUserInfo (data) {
  return reqloading({ // 需要loading加载
    url: '/user/usermanage/',
    method: 'post',
    data: data
  })
}

export function getAdminUserInfo (params) {
  return reqloading({ // 需要loading加载
    url: '/user/usermanage/',
    method: 'get',
    params: params
  })
}

export function deleteUser (id) {
  return req({
    url: `/user/usermanage/${id}/`,
    method: 'delete'
  })
}
